<template>
    <el-popover
            placement="right"
            width="400"
            trigger="click"
            v-model="isShow"
    >
        <el-form ref="form" label-position="top">
            <el-form-item :label="`请修改 ”${formVal.product_name}“ 的权值`">
                <el-input v-model="newVal"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" size="mini" @click="resetQz">修改</el-button>
                <el-button size="mini" @click="isShow = false">取消</el-button>
            </el-form-item>
        </el-form>
        <el-button slot="reference" type="text">{{formVal.qz}}</el-button>
    </el-popover>
</template>

<script>
    export default {
        name: "popoverQz",
        props: {
            formVal: {
                type: Object,
                default() {
                    return {}
                }
            }

        },
        data() {
            return {
                isShow: false,
                newVal: this.formVal.qz
            }
        },
        watch: {
            formVal(val){
                // console.log(val)
                this.newVal = val.qz
           }
        },
        methods: {
            resetQz() {
                console.log(this.newVal, this.formVal)
                this.operationProductQz()
            },
            async operationProductQz(){
                let res = await this.$Http.operationProductQz({
                   id: this.formVal.id,
                    qz: this.newVal
                })
                console.log(res)
                if(res.code === 200){
                    this.$message({
                        type: 'success',
                        message: '修改商品权值成功!',
                    })
                    this.isShow = false
                    this.$emit('reloadFun')
                }
            }
        }
    }
</script>

<style scoped>

</style>
